package com.gps.pe.mock.examples;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.gps.pe.model.Role;
import com.gps.pe.service.IRoleService;
import com.gps.pe.service.RoleService;

/**
 * This is a mock up test class to test Role Service
 * 
 * URL to access this - http://localhost:8080/placementengine/testRoleService
 * 
 * @author GPS
 *
 */
@SuppressWarnings("serial")
@WebServlet(name = "TestRoleService", urlPatterns = { "/testRoleService" })
public class TestRoleService extends HttpServlet {
	private static final Logger LOGGER = Logger.getLogger(TestRoleService.class);

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		LOGGER.info("Testing Role Service...");
		//System.out.println(req.getPathInfo());
		IRoleService roleService = new RoleService();
		Role role = roleService.getRoleById(1);
		
		if(role != null) {
			LOGGER.debug("Role details [" + role.toString() + "] for RoleId [1]");
		} else {
			LOGGER.debug("Role not found for roleId [1]");
		}
		LOGGER.info("Successfully Tested Role Service...");
	}
}
